﻿using System.Collections;

namespace BullsEyeGame
{
    internal class GameLogics
    {
        private static GameLogics s_Instance = null;
        private GameData m_GameData = null;
        public const int k_MinNumberOfGuesses = 4;
        public const int k_MaxNumberOfGuesses = 10;

        static GameLogics()
        {
            s_Instance = new GameLogics();
        }

        private GameLogics()
        {
        }

        public static GameLogics Instance
        {
            get { return s_Instance; }
        }

        public int MaxNumberOfGuessesChosen
        {
            get { return (int)m_GameData.MaxNumberOfCuessesChosen; }
        }         

        public int MinNumberOfGuesses
        {
            get { return k_MinNumberOfGuesses; }
        }

        public int MaxNumberOfGuesses
        {
            get { return k_MaxNumberOfGuesses; }
        }

        public bool IsValidNumberOfGuessesRange(int i_NumberOfRounds)
        {
            return (k_MinNumberOfGuesses <= i_NumberOfRounds) && (i_NumberOfRounds <= k_MaxNumberOfGuesses);
        }

        public void StartNewGame(int i_NumberOfRounds)
        {
            m_GameData = GameData.CreateGameData(i_NumberOfRounds);
        }       

        public Guess TargetGuess
        {
            get { return (m_GameData != null) ? m_GameData.TagetGuess : null; }
        }
        
        public ArrayList GuessesResults
        {
            get { return m_GameData.GuessesResults; }
        }

        public GuessResult AddNewGuess(Guess i_NewGuess)
        {
            return (m_GameData != null) ? m_GameData.AddNewGuess(i_NewGuess) : null; 
        }
      
    }
}
